<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>User Settings</title>
<meta http-equiv="X-UA-Compatible" content="IE=7"><meta http-equiv="Cache-Control"   content="no-cache">   <meta http-equiv="Pragma"   content="no-cache">     
<meta http-equiv="Expires" content="0"> 
<link rel="stylesheet" type="text/css" href="../web/pagestyle.css"/> 
<base target="_self" />
<script>
    document.write("<script src='/cgi-bin/acc.cgi?n=" + Math.random() + "'></" + "script>");
</script>
<script>
    var parent = window.dialogArguments;
    var index = parent.document.getElementById("index").value;

    function on_load() {       
        if (index != "") {
            index = Math.floor(index);
            document.form1.acc.value = acc[index];
            document.form1.level.value = level[index];
        } else {
            document.form1.acc.readOnly = false;
        }
    }

    function getCookie(name) {
        var allcookies = document.cookie;
        var cookie_pos = allcookies.indexOf(name);
        if (cookie_pos != -1) {
            cookie_pos += name.length + 1;
            var cookie_end = allcookies.indexOf(";", cookie_pos);
            if (cookie_end == -1) {
                cookie_end = allcookies.length;
            }
            var value = unescape(allcookies.substring(cookie_pos, cookie_end));
        }
        return value;
    }

    function SetAcc() {
        //var form = document.form1;
        if (document.form1.pwd.value == "") {
            alert("Empty password");
            return;
        }
        if (document.form1.pwd.value != document.form1.pwd2.value) {
            alert("Repeat password not match");
            return;
        }
        if (document.form1.acc.value == getCookie("User")
                && document.form1.level.value != level[index]) {
            alert("Modifying login account not allowed");
            return;
        }
        document.form1.submit();
        window.close();
    }
</script>
</head>
<body onload="on_load()" style="margin-top:5px">
<form name="form1" method='post' action="/ModifyAcc">
<table width="100%" cellspacing="3">
<tr><td width="40%" align="right">Account:</td>
<td><input name='acc' class="text" readonly="readonly"/></td></tr>
<tr><td align="right">Password:</td>
<td><input name='pwd' class="text" type="password" /></td></tr>
<tr><td align="right">Confirm:</td>
<td><input name='pwd2' class="text" type="password"/></td></tr>
<tr><td align="right">Group:</td>
<td><select name='level' class="select">
<option value="0">Guest</option>
<option value="1">User</option>
<option value="2">Administrator</option>
</select></td></tr>
</table>
<br />
<div class="tab_block"></div>
<br />
<div align="center">
<table width="74" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="18" class="TOPBG" onmouseover="this.className='TOPBGOVER';" onmouseout="this.className='TOPBG';" onclick="SetAcc();">&nbsp;&nbsp;OK</td>
</tr>
</table>
</div>
</form>
</body>
</html>
